package com.tianma.upload.uploadjartest.Test;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * @author lgc
 * @createDate 2020/8/4 - 17:59
 */
public class Hungry {
    private Hungry(){}
    private static Hungry hungry = new Hungry();
    public static Hungry getInstance(){
        return hungry;
    }
    public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        Hungry instance = Hungry.getInstance();
        Hungry instances = Hungry.getInstance();
        System.out.println("instance = " + instance);
        System.out.println("instances = " + instances);
        Constructor<Hungry> constructor = Hungry.class.getDeclaredConstructor(null);
        Hungry hungry = constructor.newInstance();
        System.out.println("hungry = " + hungry);
        Hungry hungrys = constructor.newInstance();
        System.out.println("hungrys = " + hungrys);
    }
}
